package com.example.demo.dao;

import org.springframework.data.domain.Pageable;

import java.util.Map;

/**
 * Hibernate分页处理类
 * 
 * @author jqlin
 *
 * @param <T>
 */
public class HibernatePaginationHandler<T> extends HibernateLimitationHandler<T> {

    /*private final String hql;

    private final Map<String, ?> params;

    private final Pageable pageable;*/

    public HibernatePaginationHandler(String hql, Map<String, ?> params, Pageable pageable) {
        super(hql, params, pageable.getOffset(), pageable.getPageSize());
        /*this.hql = hql;
        this.params = params;
        this.pageable = pageable;*/
    }

    /*@Override
    public T doInHibernate(Session session) throws HibernateException {
        Query query = session.createQuery(hql);
        for (Map.Entry<String, ?> param : params.entrySet()) {
            query.setParameter(param.getKey(), param.getValue());
        }
        query.setFirstResult(pageable.getOffset());
        query.setMaxResults(pageable.getPageSize());
        return (T)query.list();
    }*/
}
